//柯里化：累加
//add(1)(3,4)(3,5)
//add(2)(2)(3,5)
function add(){
    let args = Array.prototype.slice.call(arguments);
    let fn = function(){
        let arg_fn = Array.prototype.slice.call(arguments);
        return add.apply(null, args.concat(arg_fn));
    }

    //最后默认调用，返回合并的值
    fn.toString = function(){
        return args.reduce(function(a,b){
            return a+b;
        },0);
    }
    return fn;
}